﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using System.Web.UI;

namespace maintain_test.Geoinfor.CG.Beckett
{
    /// <summary>
    /// Summary description for CommonUse
    /// </summary>
    public class CommonUse
    {
        public CommonUse()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        static StringBuilder sbSQL = new StringBuilder();
        static Geoinfor.Data.DAC dac = new Geoinfor.Data.DAC();

        static public void set_DDL(ref DropDownList ddl, DataTable dt)
        {
            ddl.DataSource = dt;
            ddl.DataValueField = "TBL_value";
            ddl.DataTextField = "TBL_text";
            ddl.DataBind();

        }

        static public DataTable get_table(ref string[] vs)
        {
            DataTable tbl = new DataTable();
            tbl.Columns.Add("TBL_value");
            tbl.Columns.Add("TBL_text");
            tbl.Columns.Add("TBL_selected");
            for (int i = 0; i < vs.Length; i += 3)
            {
                DataRow dr = tbl.NewRow();
                dr["TBL_value"] = vs[i];
                dr["TBL_text"] = vs[i + 1];
                dr["TBL_selected"] = vs[i + 2];
                tbl.Rows.Add(dr);
                tbl.AcceptChanges();
            }
            return tbl;
        }

        //------鄉鎮市
        static public DataTable get_ddlCity()
        {
            string[] vs = {
         "南投市","南投市",""
        ,"埔里鎮","埔里鎮",""
        ,"草屯鎮","草屯鎮",""
        ,"竹山鎮","竹山鎮",""
        ,"集集鎮","集集鎮",""
        ,"鹿谷鄉","鹿谷鄉",""
        ,"名間鄉","名間鄉",""
        ,"中寮鄉","中寮鄉",""
        ,"魚池鄉","魚池鄉",""
        ,"國姓鄉","國姓鄉",""
        ,"水里鄉","水里鄉",""
        ,"信義鄉","信義鄉",""
        ,"仁愛鄉","仁愛鄉",""
         };
            return get_table(ref vs);
        }

        //------位置
        static public DataTable get_ddlLOC()
        {
            string[] vs = {
         "1","人行道下方",""
        ,"2","車道下方",""
        ,"3","附掛",""  
    };
            return get_table(ref vs);
        }

        //------斷面型式
        static public DataTable get_ddlTYPE()
        {
            string[] vs = {
         "1","電纜溝",""
        ,"2","纜線管路",""
        ,"3","直填埋沙",""  
        ,"9","其他",""  
    };
            return get_table(ref vs);
        }

        //子管使用狀態
        static public DataTable get_ddlUSETYPE()
        {
            string[] vs = {
         "0","申請中",""
        ,"1","已使用",""
        ,"2","已出租",""  
        ,"3","保留",""  
        ,"4","未使用",""  
        ,"5","其他",""  

    };
            return get_table(ref vs);
        }

        //alert message
        static public void AlertMessage(System.Web.UI.Page oPage, string ShowMessage)
        {
            oPage.ClientScript.RegisterStartupScript(oPage.GetType(), Guid.NewGuid().ToString(), "alert('" + ShowMessage + "');", true);
        }


        #region rent_add,rent_search,contract_search 轉換

        //getImage
        public static string GetImage(string temp)
        {
            string output = "";
            if (temp.ToString() == "0")
                output = "~/images/icon/Edit.png";
            else
                output = "~/images/icon/View.png";
            return output;
        }

        //申請狀態轉換
        public static string GetStatus(string temp)
        {
            string output = "";
            switch (temp)
            {
                case "0":
                    output = "申請";
                    break;
                case "1":
                    output = "收件";
                    break;
                case "2":
                    output = "退件";
                    break;
                case "3":
                    output = "案件核可";
                    break;
                case "4":
                    output = "通知繳費";
                    break;
                case "5":
                    output = "繳費完成";
                    break;
                case "6":
                    output = "簽約完成";
                    break;
                case "7":
                    output = "續租申請";
                    break;
                case "8":
                    output = "退租申請";
                    break;
                case "9":
                    output = "退租核定";
                    break;
                default:
                    Console.WriteLine("Default case");
                    break;
            }
            return output;
        }

        //申請類別轉換
        public static string GetType(string temp)
        {
            string output = "";
            switch (temp)
            {
                case "0":
                    output = "新申請";
                    break;
                case "1":
                    output = "續約";
                    break;
            }
            return output;

        }

        //管道使用狀態轉換
        public static string GetUseType(string temp)
        {
            string output = "";
            switch (temp)
            {
                case "0":
                    output = "申請中";
                    break;
                case "1":
                    output = "已使用";
                    break;
                case "2":
                    output = "已出租";
                    break;
                case "3":
                    output = "保留";
                    break;
                case "4":
                    output = "未使用";
                    break;
                case "5":
                    output = "其他";
                    break;
            }
            return output;

        }
        #endregion
    }
}
